package com.markerhub.mapper;

import com.markerhub.entity.TFacilityBase;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.markerhub.povo.TFacilityBaseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 刘佳明
 * @since 2021-12-10
 */
@Mapper
public interface TFacilityBaseMapper extends BaseMapper<TFacilityBase> {

//    @Select({"<script>SELECT *,(CASE type  WHEN '0' THEN '滚筒洗衣机' WHEN '1' THEN '波轮洗衣机' WHEN '2' THEN '吹风机' WHEN '3' THEN '洗鞋机' ELSE '其他' END ) as types,(CASE manufactor  WHEN '0' THEN '创维' WHEN '1' THEN '海尔'   ELSE '其他' END ) as manufactors,(CASE model  WHEN '0' THEN '无连接' WHEN '1' THEN '蓝牙模式' WHEN '2' THEN '联网模式' WHEN '3' THEN '蓝牙+ 联网 模式'    ELSE '其他' END ) as models"+
//            "FROM t_facility_base a , t_project_base b where a.projectid = b.projectid" +
//            " <if test='math!=null'>and a.number=#{math}</if>" +
//            " <if test='model &gt;0'>and a.model=#{model}</if>" +
//            " <if test='type &gt; 0'> and a.type=#{type}</if>" +
//            " <if test='math!=null'>and a.number=#{math}</if>" +
//            " <if test='projectid!=null'>and a.projectid=#{projectid}</if>" +
//            " <if test='address!=null'> and a.address=#{address}</if>" +
//            " <if test='pages &gt; 0 and limit &gt; 0'>limit #{pages}, #{limit}</if>"
//            +"</script>"})
    @Select({"<script>SELECT *," +
            "(CASE type  WHEN '0' THEN '滚筒洗衣机' WHEN '1' THEN '波轮洗衣机' WHEN '2' THEN '吹风机' WHEN '3' THEN '洗鞋机' ELSE '其他' END ) as types," +
            "(CASE manufactor  WHEN '0' THEN '创维' WHEN '1' THEN '海尔'   ELSE '其他' END ) as manufactors," +
            "(CASE model  WHEN '0' THEN '无连接' WHEN '1' THEN '蓝牙模式' WHEN '2' THEN '联网模式' WHEN '3' THEN '蓝牙+ 联网 模式'    ELSE '其他' END ) as models\n" +
            "FROM `t_facility_base` a , t_project_base b where a.projectid = b.projectid" +
            " <if test='math!=null'>and a.number=#{math} or a.blue_num= #{math} </if>" +
            " <if test='model !=null '>and a.model=#{model}</if>" +
            " <if test='type !=null and type &gt;= 0  '> and a.type=#{type}</if>" +
//            " <if test='math!=null'>and a.number=#{math}</if>" +
            " <if test='projectid!=null and projectid!= &quot;&quot;'>and a.projectid=#{projectid}</if>" +
            " <if test='address!=null and address!= &quot;&quot;'> and a.address=#{address}</if>" +
            " <if test='pages &gt;= 0 and limit &gt; 0'>limit #{pages}, #{limit}</if>"+
            " </script>"})
    List<TFacilityBaseVo> getFacilityList(@Param("pages") Integer pages, @Param("limit") Integer limit,@Param("math") String math, @Param("type")Integer type,@Param("model")Integer model, @Param("address")String address, @Param("projectid")String projectid);
}
